﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Urbania.World
{
    class Tile
    {
        protected Texture2D texture;
        protected Vector2 position;
        public static int tileWidth = 48;
        public static int tileHeight = 34;
        public static int tileTranslateWidth = 38;
        private bool willDraw;

        public TileType TileClass { get; set; }

        public Tile(Vector2 position, TileType tileType)
        {
            this.position = position;
            this.TileClass = tileType;
            this.texture = TileType.Buil_Factory.texture;
        }

        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            if(willDraw)
                spriteBatch.Draw(texture, position, Color.White);
            spriteBatch.Draw(TileClass.texture, position, Color.White);
        }

        public void Update(GameTime gameTime, Rectangle viewportBounds)
        {
            if (position.X >= viewportBounds.X - 50 && position.X  <= viewportBounds.Right + 50)
                if (position.Y >= viewportBounds.Y - 50 && position.Y <= viewportBounds.Bottom + 50)
                    willDraw = true;
                else
                    willDraw = false;
            else
                willDraw = false;
                
        }
    }
}
